FROM python:3.13.9-slim

# 设置工作目录
WORKDIR /app

# 安装系统依赖（包括Playwright所需的浏览器依赖）
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    ca-certificates \
    fonts-liberation \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libatspi2.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgbm1 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libwayland-client0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxkbcommon0 \
    libxrandr2 \
    xdg-utils \
    && rm -rf /var/lib/apt/lists/*

# 复制依赖文件
COPY requirements.txt .

# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt

# 安装Playwright浏览器
RUN playwright install chromium

# 复制脚本到 /opt/script
COPY download_script.py /opt/script/download_script.py

# 创建下载目录
RUN mkdir -p /downloads

# 设置工作目录为下载目录
WORKDIR /downloads

# 设置默认命令
CMD ["python", "/opt/script/download_script.py"]

